﻿@namespace MudBlazor.UnitTests.TestComponents

<MudTabs Elevation="1" @ref="_tabElement" AlwaysShowScrollButtons="true" Position="Position" OnPreviewInteraction="OnPreviewTabInteraction">
    @foreach (var tab in _tabs)
    {
        <MudTabPanel @key="tab" Text="@tab">
            <MudText>@tab</MudText>
        </MudTabPanel>
    }
</MudTabs>

@code
{ 
    private MudTabs _tabElement;

    public static string __description__ = "activation cancelling should work";

    [Parameter]
    public Position Position { get; set; } = Position.Top;

    private List<string> _tabs = new List<string> { "1", "2", "3", "4", "5", "6" };

    public int ActivePanel => _tabElement.ActivePanelIndex;

    public void SetPanelActive(int index)
    {
        InvokeAsync(() => _tabElement.ActivatePanel(index));
    }

    private Task OnPreviewTabInteraction(TabInteractionEventArgs args)
    {
        args.Cancel = true;

        return Task.CompletedTask;
    }
}
